#
#	Makefile for dcmjpls/apps
#

@SET_MAKE@

SHELL = /bin/sh
VPATH = @srcdir@:@top_srcdir@/include:@top_srcdir@/@configdir@/include
srcdir = @srcdir@
top_srcdir = @top_srcdir@
configdir = @top_srcdir@/@configdir@

include $(configdir)/@common_makefile@

oficonvdir = $(top_srcdir)/../oficonv
oficonvinc = -I$(oficonvdir)/include
oficonvlibdir = -L$(oficonvdir)/libsrc
oficonvlib = -loficonv

ofstddir =$(top_srcdir)/../ofstd
ofstdinc = -I$(ofstddir)/include
ofstdlibdir = -L$(ofstddir)/libsrc
ofstdlib = -lofstd

oflogdir = $(top_srcdir)/../oflog
ofloginc = -I$(oflogdir)/include
ofloglibdir = -L$(oflogdir)/libsrc
ofloglib = -loflog

dcmdatadir = $(top_srcdir)/../dcmdata
dcmdatainc = -I$(dcmdatadir)/include
dcmdatalibdir = -L$(dcmdatadir)/libsrc
dcmdatalib = -ldcmdata

dcmimgledir = $(top_srcdir)/../dcmimgle
dcmimgleinc = -I$(dcmimgledir)/include
dcmimglelibdir = -L$(dcmimgledir)/libsrc
dcmimglelib = -ldcmimgle

dcmimagedir = $(top_srcdir)/../dcmimage
dcmimageinc = -I$(dcmimagedir)/include
dcmimagelibdir = -L$(dcmimagedir)/libsrc
dcmimagelib = -ldcmimage

dcmjplsdir = $(top_srcdir)/../dcmjpls
dcmjplsinc = -I$(dcmjplsdir)/include
dcmjplslibdir = -L$(dcmjplsdir)/libsrc
dcmjplslib = -ldcmjpls

libcharlsdir = $(dcmjplsdir)
libcharlslibdir = -L$(dcmjplsdir)/libcharls
libcharlslib = -ldcmtkcharls

LOCALINCLUDES = $(dcmjplsinc) $(ofstdinc) $(ofloginc) $(dcmdatainc) $(dcmimageinc) \
	$(dcmimgleinc)
LIBDIRS = -L$(top_srcdir)/libsrc $(dcmjplslibdir) $(libcharlslibdir) $(dcmimagelibdir) \
	$(dcmimglelibdir) $(dcmdatalibdir) $(ofloglibdir) $(ofstdlibdir) $(oficonvlibdir)
LOCALLIBS = $(dcmjplslib) $(dcmimagelib) $(dcmimglelib) $(dcmdatalib) $(ofloglib) \
	$(ofstdlib)  $(oficonvlib) $(libcharlslib) $(TIFFLIBS) $(PNGLIBS) $(ZLIBLIBS) \
	$(CHARCONVLIBS) $(MATHLIBS)

objs = dcmdjpls.o dcmcjpls.o dcml2pnm.o
progs = dcmdjpls dcmcjpls dcml2pnm


all: $(progs)

dcmdjpls: dcmdjpls.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(LOCALLIBS) $(LIBS)

dcmcjpls: dcmcjpls.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(LOCALLIBS) $(LIBS)

dcml2pnm: dcml2pnm.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ $@.o $(LOCALLIBS) $(LIBS)


install: all
	$(configdir)/mkinstalldirs $(DESTDIR)$(bindir)
	for prog in $(progs); do \
		$(INSTALL_PROGRAM) $$prog$(BINEXT) $(DESTDIR)$(bindir) && $(STRIP) $(DESTDIR)$(bindir)/$$prog$(BINEXT) ;\
	done


clean:
	rm -f $(objs) $(progs) $(TRASH)

distclean:
	rm -f $(objs) $(progs) $(DISTTRASH)


dependencies:
	$(CXX) -MM $(defines) $(includes) $(CPPFLAGS) $(CXXFLAGS) *.cc  > $(DEP)

include $(DEP)
